﻿<%@ Control Language="C#" ClassName="PaymentFields" %>
<asp:FormView ID="FormView1" runat="server">
    <ItemTemplate>

        <script src="https://www.google.com/jsapi" type="text/javascript"></script>

        <script language="javascript" type="text/javascript">
        google.load("language", "1");
        var apiKey = "AIzaSyCmYKgS2nT4WLhK0XoIvvmH5vFxTcxdffs";

            function GoogleTranslate(e) {

                var text = $.trim($(e).val());
                var translatedText = $('.TranslateResult').val();
                if (text.length > 0 && translatedText.length==0) {
                        var apiurl = "https://www.googleapis.com/language/translate/v2?key=" + apiKey + "&source=en&target=vi&q=";

                        $.ajax({
                            url: apiurl + encodeURIComponent(text),
                            dataType: 'jsonp',
                            async: false,
                            success: function (data) {
                                try {
                                    $('.TranslateResult').val(data.data.translations[0].translatedText);
                                }
                                catch (e) {
                                    $('.TranslateResult').val(text);
                                }
                                //$('#divTranslated').css({ "border": "1px solid #7F9DB9" });
                                //$('#divTranslated').css({ "padding": "4 4 4 4" });

                                //$('#lblTranslation').css({ "color": "black" });
                            },
                            error: function (x, e) {
                                alert('Error occured while translating the text');
                            }
                        });
                }
                else {
                    ;
                    //$.unblockUI();
                }
            //$.unblockUI();
        };
        </script>

        <%--<script type="text/javascript">
            
            function GoogleTranslate(obj) {
                $(".TranslateResult").val($(obj).val());
            }
        </script>
--%>
        <table border="0" cellpadding="3" cellspacing="1" width="100%">
            <tr>
                <td class="literal">
                    <asp:Label ID="lbldataPaymentId" runat="server" Text="Payment Id:" AssociatedControlID="dataPaymentId" />
                </td>
                <td>
                    <asp:TextBox runat="server" ID="dataPaymentId" Text='<%# Bind("PaymentId") %>' MaxLength="10"
                        Enabled="False" CssClass="text-input large-input" />
                </td>
            </tr>
            <tr>
                <td class="literal">
                    <asp:Label ID="lbldataPaymentDate" runat="server" Text="Payment Date:" AssociatedControlID="dataPaymentDate" />
                </td>
                <td>
                    <asp:TextBox runat="server" ID="dataPaymentDate" Text='<%# Bind("PaymentDate", "{0:d}") %>'
                        MaxLength="11" CssClass="text-input large-input datepicker"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="literal">
                    <asp:Label ID="lbldataPaymentTypeId" runat="server" Text="Payment Type Id:" AssociatedControlID="dataPaymentTypeId" />
                </td>
                <td>
                    <data:EntityDropDownList runat="server" ID="dataPaymentTypeId" DataSourceID="PaymentTypeIdPaymentTypeDataSource"
                        DataTextField="Description" DataValueField="PaymentTypeId" SelectedValue='<%# Bind("PaymentTypeId") %>'
                        AppendNullItem="true" Required="true" NullItemText="< Please Choose ...>" ErrorText="Required"
                        CssClass="text-input large-input" ValidationGroup="Entity" />
                    <data:PaymentTypeDataSource ID="PaymentTypeIdPaymentTypeDataSource" runat="server"
                        SelectMethod="GetAll" />
                </td>
            </tr>
            <tr>
                <td class="literal">
                    <asp:Label ID="lbldataReceivedBy" runat="server" Text="Received By:" AssociatedControlID="dataReceivedBy" />
                </td>
                <td>
                    <asp:TextBox runat="server" ID="dataReceivedBy" Text='<%# Bind("ReceivedBy") %>'
                        MaxLength="100" CssClass="text-input large-input"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="literal">
                    <asp:Label ID="lbldataAddress" runat="server" Text="Address:" AssociatedControlID="dataAddress" />
                </td>
                <td>
                    <asp:TextBox runat="server" ID="dataAddress" Text='<%# Bind("Address") %>' MaxLength="100"
                        CssClass="text-input large-input"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="literal">
                    <asp:Label ID="lbldataDescription" runat="server" Text="Description:" AssociatedControlID="dataDescription" />
                    <br />
                    <asp:Label ID="lbldataDescriptionVn" runat="server" Text="Translated Text:" AssociatedControlID="dataDescriptionVn" />
                </td>
                <td>
                    <asp:TextBox runat="server" ID="dataDescription" Text='<%# Bind("Description") %>'
                        MaxLength="100" CssClass="text-input large-input" onblur="javascript:GoogleTranslate(this)"></asp:TextBox>
                    <br />
                    <asp:TextBox runat="server" ID="dataDescriptionVn" Text='<%# Bind("DescriptionVn") %>'
                        CssClass="text-input large-input TranslateResult" MaxLength="100"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="literal">
                    <asp:Label ID="lbldataAmount" runat="server" Text="Amount:" AssociatedControlID="dataAmount" />
                </td>
                <td>
                    <asp:TextBox runat="server" ID="dataAmount" Text='<%# Bind("Amount") %>' CssClass="text-input large-input"
                        Enabled="False"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="literal">
                    <asp:Label ID="lbldataExchangeRate" runat="server" Text="Exchange Rate:" AssociatedControlID="dataExchangeRate" />
                </td>
                <td>
                    <asp:TextBox runat="server" ID="dataExchangeRate" Text='<%# Bind("ExchangeRate") %>'
                        CssClass="text-input large-input"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="literal">
                    <asp:Label ID="lbldataPreparedBy" runat="server" Text="Prepared By:" AssociatedControlID="dataPreparedBy" />
                </td>
                <td>
                    <data:EntityDropDownList runat="server" ID="dataPreparedBy" DataSourceID="PreparedByInvoiceCheckingUserDataSource"
                        DataTextField="Fullname" DataValueField="UserId" SelectedValue='<%# Bind("PreparedBy") %>'
                        Enabled="False" AppendNullItem="true" Required="false" NullItemText="< Please Choose ...>"
                        CssClass="text-input large-input" />
                    <data:InvoiceCheckingUserDataSource ID="PreparedByInvoiceCheckingUserDataSource"
                        runat="server" SelectMethod="GetAll" />
                </td>
            </tr>
        </table>
    </ItemTemplate>
</asp:FormView>
